package com.pzhu.dormitory.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pzhu.dormitory.vo.BuildingVo;
import com.pzhu.dormitory.vo.RoomVo;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pzhu.dormitory.utils.PageUtils;
import com.pzhu.dormitory.utils.Query;

import com.pzhu.dormitory.dao.RoomDao;
import com.pzhu.dormitory.entity.RoomEntity;
import com.pzhu.dormitory.service.RoomService;


@Service("roomService")
@AllArgsConstructor
public class RoomServiceImpl extends ServiceImpl<RoomDao, RoomEntity> implements RoomService {

    private final RoomDao roomDao;
    @Override
    public PageUtils<RoomEntity> queryPage(Map<String, Object> params) {
        IPage<RoomEntity> page = this.page(
                new Query<RoomEntity>().getPage(params),
                new QueryWrapper<>()
        );
        return new PageUtils<>(page);
    }

    @Override
    public PageUtils<RoomVo> queryPageRoomVo(Map<String, Object> params) {
        Page<RoomVo> page = new Query<RoomVo>().getPage(params);
        // 查询基本数据
        Page<RoomVo> roomVoPage = roomDao.queryPageVo(page, params);
        return new PageUtils<>(roomVoPage);
    }

}
